package com.corpgovernment.common.mq;

import org.apache.rocketmq.common.message.Message;

import static com.ctrip.corp.obt.generic.constants.GenericConstants.CLIENT_ID;
import static com.ctrip.corp.obt.generic.constants.GenericConstants.TENANT_ID;

/**
 * @author marco.zheng   (cq_zheng@trip.com)
 * @date 2023/11/27
 */
public class MessageWrapper {

    private final Message message;

    public MessageWrapper(Message message) {
        this.message = message;
    }

    public MessageWrapper setTenantId(String tenantId) {
        message.putUserProperty(TENANT_ID, tenantId);
        return this;
    }

    public MessageWrapper setClientId(String clientId) {
        message.putUserProperty(CLIENT_ID, clientId);
        return this;
    }
    
    public Message getMessage() {
        return message;
    }

    public String getTenantId() {
        return message.getProperty(TENANT_ID);
    }

    public String getClientId() {
        return message.getProperty(CLIENT_ID);
    }
}
